@import '../../../../variables';

$noteFontSize: 14px;

:host {
  display: block;

  :host-context([dir='rtl']) {
    margin-right: unset;
  }
}

.note {
  @include noteStyle;

  overflow: hidden;

  &:hover,
  &.isFocused {
    transform-origin: center center;
    position: relative;
    z-index: 4;
    box-shadow: $whiteframe-shadow-3dp;
    //outline: 2px dashed $c-accent;
  }

  &.isFocused {
    z-index: 5;
  }

  &.isImg {
    border: 0;
  }

  :host.gu-mirror & {
    box-shadow: $whiteframe-shadow-8dp !important;
  }
}

.controls {
  position: absolute;
  top: -$s * 0.75;
  right: -$s * 0.75;

  :host-context([dir='rtl']) & {
    position: absolute;
    right: unset;
    left: -$s * 0.75;
  }

  // fixes drag and drop on mobile
  touch-action: none;

  @include mq(xs) {
    opacity: 0;
    transition: $transition-standard;

    .note:focus &,
    .note:hover & {
      opacity: 1;
    }
  }
}

.note-img {
  max-width: 100%;
  border-radius: $card-border-radius;
  cursor: zoom-in;
}

.content {
  text-align: start;
  font-size: $noteFontSize;

  inline-markdown ::ng-deep {
    .markdown-wrapper {
      min-height: 40px;
    }

    .markdown-unparsed,
    .markdown-parsed {
      font-size: $noteFontSize;
      border-radius: $card-border-radius;
      background: #ffffff;
      color: $standard-note-fg-light;
      box-sizing: border-box;

      @include darkTheme {
        background: $standard-note-bg-dark;
        color: $standard-note-fg-dark;
        border-color: #333333;
      }
    }

    .markdown-unparsed,
    .markdown-parsed > *:first-child {
      padding-right: $s * 1.25;
    }

    .markdown-parsed > *:last-child {
      margin-bottom: 0;
    }
  }
}

// copied from inline-markdown component
.markdown-preview {
  border: 0;
  padding: $s $s * 2;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  word-wrap: break-word;
  display: block;
  resize: none;
  min-height: inherit;
  min-height: 40px;
  overflow: hidden;
  cursor: text;
}

:host:hover .bottom-controls {
  opacity: 1;

  &.isOver {
    opacity: 0.8;
  }
}

.bottom-controls {
  display: flex;
  align-items: center;
  transition: $transition-standard;
  cursor: grab;
  cursor: move;
  border-top: 1px dashed $dark-theme-extra-border-color;
  opacity: 0;

  @include lightTheme() {
    border-color: $light-theme-extra-border-color;
  }

  @include touchOnlyDevice() {
    opacity: 1;
  }

  @include mq(xs) {
    position: relative;
    z-index: 1;
    margin-top: -8px;
  }

  &:active {
    cursor: grabbing;
  }

  &.isOver {
    background: inherit;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
  }

  tag {
    margin: auto;
    pointer-events: none;
    opacity: 1;
  }

  button:first-of-type {
    margin-right: auto;
  }

  button:last-of-type {
    margin-left: auto;
    margin-right: 0;
  }

  .mat-icon-button {
    height: 36px;
    width: 36px;
    line-height: 36px;
  }
}
